﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class FAQ_FAQ : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //判断用户身份的代码 
            string EncrTicket = Request.Cookies[FormsAuthentication.FormsCookieName].Value;
            //获得身份验证票  
            FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(EncrTicket);
            //从身份验证票中提取经过验证的用户名  
            string UserName = ticket.Name;
            Label9.Text = UserName;
        }
    }
    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
       
            FAQ f = new FAQ();
            f.InsertFAQ(TextBox1.Text, null, 0);
            TextBox1.Text = "";
            GridView1.DataSource = f.GetAll();
            GridView1.DataBind();
        
    }
    protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {

    }
    protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {

    }
    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {

    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {

    }
    protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e)
    {

    }
    protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {

    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {

        FAQ faq = new FAQ();
        GridView1.DataSource = faq.returnfaq();
        GridView1.DataBind();
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
       FAQ f = new FAQ();
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            CheckBox cb = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
            if (cb.Checked)
            {
                int str;
                str = Convert.ToInt32(GridView1.Rows[i].Cells[0].Text);  //获取此项ID

                f.DeleteFAQ(str);    //删除对应项
            }
        }
        GridView1.DataSource = f.returnfaq();
        GridView1.DataBind();
    }
}